<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
		<meta charset="utf-8" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />



</head>


<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">我的实习</a></li>
    <li><a href="#">实习问题</a></li>
    </ul>
    </div>
    <div class="rightinfo">
    <div class="tools">
		<ul class="toolbar">
        <li class="click add"><span><img src="images/t01.png" /></span>添加</li>
        </ul>
         <form id="searchForm" class="form-search"
						action="question/myQuestion_page_list.do" method="post">
						 <input type="hidden" name="pageNumber" value="1" />
					</form>
    </div>
    <table class="tablelist">
    	<thead>
    	<tr>
    	<th>姓名</th>
        <th>问题内容</th>
        <th >提问日期</th>
		<th>是否回复</th>
       <th>操作</th>
      </tr>
        </thead>
        <tbody>
         <c:forEach items="${questionList}" var="question"  varStatus="status">
      <tr>
       <td>${question.studentName}</td>
        <td style="width: 50%;">${question.question}</td>
         <td>${question.sendTime}</td>
        <td><c:if test="${question.hasReply==1}">已回复</c:if>
        <c:if test="${question.hasReply==0}">未回复</c:if></td>
		<td><a onclick="check('${question.id}');">查看</a>&nbsp;&nbsp;&nbsp;&nbsp;
			<a  onclick="deleteQuestion('${question.id}');">删除</a></td>
		</tr>
		</c:forEach>
        </tbody>
    </table>
   <div class="pagin">
    	<%@ include file="page.jsp"%>
    </div>
    </div>
    <script src="js/jquery-1.7.2.js"></script>
    <script src="layer/layer.js"></script>
     <script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
	$( "#btnSearch" ).on('click', function(e) {
		$("#searchForm").submit();
	});
	function GoToPage(toPage,totalPage) {
	    if(toPage<=0) return;
	    if(toPage>totalPage) return;
	    $("input[name='pageNumber']").val(toPage);
	    $("#searchForm").submit();
	};
	
	function closeAll() {
		layer.alert('添加成功!', {
			skin : 'layer-ext-moon'
		}, function() {
			layer.closeAll(); 
			 location.reload();
		}); 
	}
	$(".add").click(
	function  () {
		layer.open({
  type: 2,
  closeBtn: 2,
  title: '新增问题',
  shadeClose: true,
  shade: 0.6,
  area: ['600px', '300px'],
  content: 'question/question_add.do',
  end: function () {
      location.reload();
  }
});
	}
	);
	function check(id){
		layer.open({
	  type: 2,
	   closeBtn: 2,
	  title: '问题回复',
	  shadeClose: true,
	  shade: 0.8,
	  area: ['600px', '500px'],
	  content:'question/question_reply_list.do?QuestionId='+id  ,//iframe的url
	  end: function () {
	      location.reload();
	  }
		});
	  }
	function deleteQuestion(id) {
		$.ajax({
			type: "GET",
			url: "question/delete.do?id="+id,
			async: true,
			dataType: "json",
			success: function(data) {
				if("success" == data.result){
					layer.alert('删除成功!', {
			            skin: 'layer-ext-moon' 
					}, function(){
					 location.reload();
					 });
					}else {
						layer.alert('删除失败!', {
				            skin: 'layer-ext-moon' 
				        });
						}
				}
			})
	};
	</script>
</body>

</html>
